import com.dmotiko.bolacua.*
import com.dmotiko.general.*
import com.dmotiko.util.*
import mx.utils.Delegate

class MainContentBolacua 
extends BaseClip {
	
	private var container:MovieClip;
	private var mcl:MovieClipLoader;
	private var sSection:String;
	
	private function MainContentBolacua(){
		BolacuaSite.getApp().setMainContentBolacua(this);
	}
	
	private function initClip():Void {
		container = DummyFactory.getNextDummy(this);
		mcl = new MovieClipLoader();
		mcl.addListener(this);
		BolacuaSite.getApp().addEventListener( BolacuaSite.SECTION_CHANGED, Delegate.create(this, sectionChanged) );
	}
	
	function onLoadStart(){
		
	}

	function onLoadProgress(target, loaded, total){
		
		_root.CONTENT_LOADER.setPos( Math.round( loaded * 100 / total ) );
	}

	function onLoadInit(){
		_root.CONTENT_LOADER._visible = false;
		_root.CONTENT_LOADER.setPos(0);
		BolacuaSite.getApp().getCanvasBolacua().sectionChanged();
		switch(sSection){
			case BolacuaSite.HOME:
			BolacuaSite.getApp().setMainBannerBolacua(container);
			break;
		}
	}
	
	private function sectionChanged(){
		
		sSection = BolacuaSite.getApp().getSection();
		BolacuaSite.getApp().log("MainContentBolacua | sectionChanged " + sSection);
		
		var sText:String = "";
		switch(BolacuaSite.getApp().getSection()){
			case BolacuaSite.HOME:
			mcl.loadClip("homeBanners.swf", container);
			break;
			
			case BolacuaSite.ALOJAMIENTO:
			sText = "cargando alojamiento";
			mcl.loadClip( "alojamiento.swf", container );
			//mcl.loadClip( "http://zutabedecangas.files.wordpress.com/2007/09/ukelele.jpg?"+new Date().getTime(), container );
			break;
			
			case BolacuaSite.TARIFAS:
			
			mcl.loadClip( "tarifas.swf", container );
			break;
			
			case BolacuaSite.INFRAESTRUCTURA:
			sText = "cargando infraestructura";
			mcl.loadClip( "infraestructura.swf", container );
			break;
			
			case BolacuaSite.COMO_LLEGAR:
			sText = "cargando como llegar";
			mcl.loadClip( "comoLLegar.swf", container );
			break;
			
			case BolacuaSite.RESTAURANT:
			sText = "cargando restaurante";
			mcl.loadClip( "restaurante.swf", container );
			break;
			
			case BolacuaSite.EVENTOS:
			sText = "cargando eventos";
			mcl.loadClip( "eventos.swf", container );
			break;
			
			case BolacuaSite.CONTACTO:
			sText = "cargando contacto";
			mcl.loadClip( "contacto.swf", container );
			break;
		}
		_root.CONTENT_LOADER._visible = true;
		_root.CONTENT_LOADER.txtLabel.text = sText;
		_root.CONTENT_LOADER.setPos(0);
		BolacuaSite.getApp().getCanvasBolacua().loadingSection();
	}
	
}